<?php

//TOOLS
include_once 'application/tools/Authentification.php';

//MODELS
include_once 'application/models/Project.php';
include_once 'application/models/Member.php';

/**
 * HTML class
 */
class Html {

    /**
     * Ouverture de la page HTML
     */
    static public function open() {
        $settings = Settings::getInstance($_SERVER["DOCUMENT_ROOT"]."/WSK_PORTAL/config/config.ini"); 
        $siteName = $settings->site_name;
        echo '<!DOCTYPE html>
<html>
    <head>
    	<meta http-equiv="Content-type" content="text/html;charset=utf-8" />
        <title>'. $siteName .'</title>
        <link rel="stylesheet" href="public/css/style.css" type="text/css" />
        <link rel="stylesheet" type="text/css" href="public/css/jquery.jqplot.min.css" />
        <link href="public/css/custom-theme/jquery-ui-1.8.16.custom.css" rel="stylesheet" type="text/css"/>
        <link href="public/css/jquery.multiselect.css" rel="stylesheet" type="text/css"/>
        <link href="public/css/jquery.dataTables.css" rel="stylesheet" type="text/css"/>
        <link href="public/css/jquery.dataTables_themeroller.css" rel="stylesheet" type="text/css"/>
        <link href="public/css/chosen.css" rel="stylesheet" type="text/css"/>
        <link href="public/css/bootstrap.css" rel="stylesheet" type="text/css"/>
        <link href="public/css/bootstrap-responsive.css" rel="stylesheet" type="text/css"/>
        <link href="public/css/jquery.dataTables.tableTools.css" rel="stylesheet" type="text/css"/>
        
        <script src="public/js/jquery-1.7.min.js" type="text/javascript"></script>
        <script src="public/js/jquery-ui-1.8.16.custom.min.js" type="text/javascript"></script>
        <script type="text/javascript" src="public/js/jquery.jqplot.min.js"></script>
        
        <script type="text/javascript" src="public/js/jquery-ui-timepicker-addon.js"></script>
        <script type="text/javascript" src="public/js/plugins/jqplot.barRenderer.min.js"></script>
        <script type="text/javascript" src="public/js/plugins/jqplot.highlighter.min.js"></script>
        <script type="text/javascript" src="public/js/plugins/jqplot.cursor.min.js"></script>
        <script type="text/javascript" src="public/js/plugins/jqplot.pointLabels.min.js"></script>
        <script type="text/javascript" src="public/js/plugins/jqplot.dateAxisRenderer.min.js"></script>
        <script type="text/javascript" src="public/js/plugins/jqplot.logAxisRenderer.min.js"></script>
        <script type="text/javascript" src="public/js/plugins/jqplot.canvasTextRenderer.min.js"></script>
        <script type="text/javascript" src="public/js/plugins/jqplot.canvasAxisTickRenderer.min.js"></script>
        <script type="text/javascript" src="public/js/plugins/jqplot.enhancedLegendRenderer.min.js"></script>
        <script type="text/javascript" src="public/js/plugins/jqplot.pieRenderer.min.js"></script>
        <script type="text/javascript" src="public/js/jquery.json-2.3.min.js"></script>
        <script type="text/javascript" src="public/js/chart.js"></script>
        <script type="text/javascript" src="public/js/jquery.multiselect.min.js"></script>
        <script type="text/javascript" src="public/js/jquery.dataTables.min.js"></script>
        <script type="text/javascript" src="public/js/chosen.jquery.js"></script>
        <script type="text/javascript" src="public/js/kcp.print.js"></script>
        <script type="text/javascript" src="public/js/bootstrap-dropdown.js"></script>
        <script language="javascript" type="text/javascript" src="public/js/excanvas.min.js"></script>
        
        <script src="public/js/admin.js" type="text/javascript"></script>        		
        <script src="public/js/init.js" type="text/javascript"></script>
        
        <!--[if lt IE 9]>
        	<style>
        		.ui-icon-print, .ui-icon-image { display:none; }
            </style>
        <![endif]-->
        
        <!--[if IE]>
        	<style>
        		#page-content { padding-bottom:60px; }
            </style>
        <![endif]-->
        
    </head>
    
    <body id="index" class="home">
        <!-- HEADER -->
        
        <div id="container">
            <div id="top">
                <div id="header">
                    
                    ';
        if(Authentification::isAuthenticated()) Html::header();
		echo '
                </div>
                
        <!-- END HEADER -->
        ';
    }
    
    /**
     * Création du header HTML
     */
    private static function header() {
        $page = (Page::getCurrentPage() == Page::GRAPH) ? Page::GRAPH : Page::ADMIN;
        $active = "class='active'"; 
    	$title = (Page::getCurrentPage() == Page::GRAPH) ? "Administration" : "Retour aux projets";
        ?>
        
        <div class="navbar navbar-fixed-top">
                    <div class="navbar-inner">
                        <div class="container">
                            <button type="button" class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
                                <span class="icon-bar"></span>
                                <span class="icon-bar"></span>
                                <span class="icon-bar"></span>
                            </button>
                            <a class="brand" href="main.php?page=0">WSK PORTAL</a>
                            <div class="nav-collapse collapse">
                                <ul class="nav">
                                    <li <?php if($page == Page::GRAPH) echo $active ?>>
                                        <a href="main.php?page=0">Accueil</a>
                                    </li>
                                    <?php if(Authentification::canAdminAcces()){
                                        ?>
                                    <li <?php if($page == Page::ADMIN) echo $active ?>>
                                        <a href='main.php?page=1'>Administration</a>
                                    </li>
                                   <?php }
                                    ?>
                                    

                                    <li class="dropdown">
                                        <a href="#" class="dropdown-toggle" data-toggle="dropdown">Projet <b class="caret"></b></a>
                                        <?php echo GrapheController::getProjectsForSelectedList(); ?>
                                    </li>
                                </ul>
                                <ul class="nav pull-right">
                                    
                                    <li class="dropdown" id="nav-user">
                                        <a href="#" class="dropdown-toggle" data-toggle="dropdown">
                                            
                                            Bonjour <?php echo Authentification::getCurrentMemberName(); ?>
                                            <b class="caret"></b>
                                        </a>
                                        <ul class="dropdown-menu">
                                            <li class="">
                                                <a href="main.php?page=0"><i class="picons-16-basic2-031"></i>
                                                    Accueil
                                                </a>
                                            </li>
                                            
                                            <li class="divider"></li>
                                            <li>
                                                <a href="index.php"><i class="picons-16-basic2-171"></i>
                                                    Se d&eacute;connecter
                                                </a>
                                            </li>
                                        </ul>
                                    </li>
                                </ul>
                            </div>
                        </div>
                    </div>
                </div>
<?php

    	echo '
			<a href="main.php?page=0"><img name="logo" id="logo" src="public/img/logo.png" alt="Logo Ateliers Laumonier"></img></a>
            <h1 id="title-project">' . Page::getCurrentPageName() . '</h1>';
            //<label id="label-hello"> Bonjour '. Authentification::getCurrentMemberName() .'</label>';
    	
    	
		
        
    } 
    
    /**
     * Footer de la page
     */
    private static function footer() {
        $settings = Settings::getInstance($_SERVER["DOCUMENT_ROOT"]."/WSK_PORTAL/config/config.ini"); 
        $siteName = $settings->site_name;
        $footerMain = $settings->footer_main_url;
        $footerAtelier = $settings->footer_atelier_url;
    	echo '
           
        <!-- FOOTER -->
            <div id="footer">
                <div id="foot"> 
                    <div id="left">
                        <p><a href="' . $footerMain . '">WSK PORTAL</a></p>
                        <p>'.$siteName.'</p>
                    </div>
                    <div id="right">
                        <p>R&eacute;alis&eacute; par  <a href="'. $footerAtelier .'" title="Atelier Laumoniers">Les Ateliers Laumonier</p>
                    </div>
                </div>
            </div>
       <!-- END FOOTER -->';
    }

    /**
     * Fermeture de la page HTML
     */
    static public function close() {
    	echo '</div>';
        if(Authentification::isAuthenticated()) Html::footer();
    	echo '
    </body>
</html>
';
    }
    
    

}

